package name.matthewgreet.example6.action; import javax.servlet.http.HttpSession; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.InterceptorRef; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import com.opensymphony.xwork2.ActionSupport; import name.matthewgreet.example6.action.FindUserRatingListByRatingAction.UserRatingByRatingListFinder; import name.matthewgreet.example6.action.FindUserRatingListByUsernameContainsAction.UserRatingByNameContainsListFinder; import name.matthewgreet.example6.dto.GameDTO; import name.matthewgreet.example6.dto.UserRatingDTO; import name.matthewgreet.example6.form.UserRatingRatingForm; import name.matthewgreet.example6.form.UserRatingUsernameContainsForm; import name.matthewgreet.example6.model.UserRatingPK; import name.matthewgreet.example6.util.GameCompositeCache; import name.matthewgreet.example6.view.GameDetailDisplay; import name.matthewgreet.example6.view.RatingSelectBoxDisplay; import name.matthewgreet.example6.view.UserRatingListDisplay; import name.matthewgreet.strutscommons.action.AbstractViewActionSupport; import name.matthewgreet.strutscommons.util.ListCache; import name.matthewgreet.strutscommons.util.NA; /** * Displays search results of user ratings for a game. */ @InterceptorRef("ViewStack") @Results({ @Result(name="list", type="redirectAction", params = {"namespace", "/", "actionName", "ViewGameList"}), @Result(name=ActionSupport.SUCCESS, location="/pages/UserRatingList.jsp") }) public class ViewUserRatingListAction extends AbstractViewActionSupport { private static final long serialVersionUID = -7979376337555804889L; public static final int PAGE_SIZE = 15; private Integer masterRecordNo; private Integer pageNo; private String refresh; private UserRatingRatingForm userRatingRankForm; private UserRatingUsernameContainsForm userRatingUsernameContainsForm; private GameDetailDisplay gameDetailDisplay; private UserRatingListDisplay listDisplay; private RatingSelectBoxDisplay ratingSelectBoxDisplay; @Action("/ViewUserRatingList") @Override public String execute() throws Exception { ListCache<NA,Integer,GameDTO> masterListCache; ListCache<GameDTO,UserRatingPK,UserRatingDTO> listCache; UserRatingByNameContainsListFinder userRatingByNameContainsListFinder; UserRatingByRatingListFinder userRatingByRatingListFinder; HttpSession session; session = getBrowserTabSession(); masterListCache = GameCompositeCache.getInstance(session).getMasterListCache(); if (masterListCache.getReload()) { // No list due to expired session return "list"; } listCache = GameCompositeCache.getInstance(session).getSlaveListCache2(); if (masterRecordNo != null) { masterListCache.setSelectedIndex(masterRecordNo - 1); } if (refresh != null) { listCache.forceReload(); } if (pageNo != null) { listCache.setPageNo(pageNo); } if (userRatingRankForm == null) { if (listCache.getBaseRecordListFinder() instanceof UserRatingByRatingListFinder) { userRatingByRatingListFinder = (UserRatingByRatingListFinder)listCache.getBaseRecordListFinder(); userRatingRankForm = new UserRatingRatingForm(userRatingByRatingListFinder.getRating()); } else { userRatingRankForm = new UserRatingRatingForm(); } } if (userRatingUsernameContainsForm == null) { if (listCache.getBaseRecordListFinder() instanceof UserRatingByNameContainsListFinder) { userRatingByNameContainsListFinder = (UserRatingByNameContainsListFinder)listCache.getBaseRecordListFinder(); userRatingUsernameContainsForm = new UserRatingUsernameContainsForm(userRatingByNameContainsListFinder.getUsernameContains()); } else { userRatingUsernameContainsForm = new UserRatingUsernameContainsForm(); } } gameDetailDisplay = new GameDetailDisplay(masterListCache); gameDetailDisplay.setBrowserTabSessionData(getBrowserTabSession(), GameCompositeCache.class, getTabId()); gameDetailDisplay.init(); listDisplay = new UserRatingListDisplay(listCache); listDisplay.init(); ratingSelectBoxDisplay = new RatingSelectBoxDisplay(); ratingSelectBoxDisplay.setSelectedValue(userRatingRankForm.getRating()); return SUCCESS; } public Integer getMasterRecordNo() { return masterRecordNo; } public void setMasterRecordNo(Integer masterRecordNo) { this.masterRecordNo = masterRecordNo; } public Integer getPageNo() { return pageNo; } public void setPageNo(Integer pageNo) { this.pageNo = pageNo; } public String getRefresh() { return refresh; } public void setRefresh(String refresh) { this.refresh = refresh; } public GameDetailDisplay getGameDetailDisplay() { return gameDetailDisplay; } public UserRatingListDisplay getListDisplay() { return listDisplay; } public UserRatingRatingForm getUserRatingRankForm() { return userRatingRankForm; } public UserRatingUsernameContainsForm getUserRatingUsernameContainsForm() { return userRatingUsernameContainsForm; } public RatingSelectBoxDisplay getRatingSelectBoxDisplay() { return ratingSelectBoxDisplay; } }